﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.IO;
using QQHelper;
using System.Net;

namespace QQLogin
{
    /// <summary>
    /// QQMain.xaml 的交互逻辑
    /// </summary>
    public partial class QQMain : Window
    {
        private DispatcherTimer _Timer;
        private List<QQMenu> _menulist = new List<QQMenu>();
        public QQMain()
        {
            InitializeComponent();
            tb_NowTime.Text = DateTime.Now.ToString("yyyy年MM月dd日 hh:mm:ss");
            CreateTimer();
            Init();
        }
        #region 日期
        /// <summary>
        /// 创建定时器
        /// </summary>
        private void CreateTimer()
        {
            _Timer = new System.Windows.Threading.DispatcherTimer();
            _Timer.Tick += new EventHandler(_Timer_Tick);
            _Timer.Interval = new TimeSpan(0, 0, 0, 1, 0);
            _Timer.Start();
        }
        void _Timer_Tick(object sender, EventArgs e)
        {
            tb_NowTime.Text = DateTime.Now.ToString("yyyy年MM月dd日 hh:mm:ss");
        }
        #endregion
        /// <summary>
        /// 初始化
        /// </summary>
        private void Init()
        {
            _menulist.Add(new QQMenu() { ID = "001", Name = "QQ空间" });
            _menulist.Add(new QQMenu() { ID = "002", Name = "QQ群" });
            lv_MenuData.ItemsSource = _menulist;
            lv_MenuData.DisplayMemberPath = "Name";
            lv_MenuData.SelectionChanged -= new SelectionChangedEventHandler(lv_MenuData_SelectionChanged);
            lv_MenuData.SelectionChanged += new SelectionChangedEventHandler(lv_MenuData_SelectionChanged);
            lv_MenuData.SelectedIndex = 0;
        }

        void lv_MenuData_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            QQMenu menu = lv_MenuData.SelectedItem as QQMenu;
            if (menu == null) return;
            if (menu.ID == "001")
            {
                QQZoneMain qqzone = new QQZoneMain();
                grid_Main.Children.Add(qqzone);
            }
            if (menu.ID == "002")
            {
                grid_Main.Children.Clear();
                QQGroupManagerCtrl group = new QQGroupManagerCtrl();
                grid_Main.Children.Add(group);
            }
        }


        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string allgroupurl = @"http://qun.qzone.qq.com/cgi-bin/get_group_list?uin={0}&g_tk={1}";
            //string url = @"http://qun.qzone.qq.com/cgi-bin/get_group_member?uin={0}&groupid=24756069&g_tk={1}";

        }
    }
}
